<?php

namespace App\Http\Resources;

use App\Helpers\BaseResource;
use App\Helpers\FileTool;

class Ad extends BaseResource
{
    public function toArray($request)
    {
        return $this->filterFields([
            'id' => hashid_encode($this->id),
            'title' => $this->title,
            'describe' => $this->describe,
            'cover' => FileTool::thumb($this->cover, FileTool::getImageView($this->ad_position->cover_w, $this->ad_position->cover_h)),
            'href' => \App\Models\Ad::getHref($this),
            'event' => $this->event,
            'check_login' => (boolean)$this->check_login,
            'new_open' => (boolean)$this->new_open,
        ]);
    }
}
